﻿using SAD_Assignment1.DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SAD_Assignment1.Shared
{
    public partial class Site1 : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            initialComponent();
            if (Session["account"] != null)
            {
                AccountDTO accDTO = (AccountDTO)Session["account"];
                EmailLB.Text = accDTO.Name;
                LoginHL.Text = "Thoát";
                LoginHL.NavigateUrl = Resource.Login + "?logout=";
                PersonalDD.Visible = true;
                RegisterHL.Visible = false;
                myAccHL.NavigateUrl = Resource.MyAccount;
                if ("admin".Equals(accDTO.Roles))
                {
                    AccListHL.Visible = true;
                }
            }
            else
            {
                LoginHL.Text = "Đăng nhập";
                LoginHL.NavigateUrl = Resource.Login;
                PersonalDD.Visible = false;
                RegisterHL.NavigateUrl = Resource.Register;
                RegisterHL.Visible = true;
            }
        }

        private void initialComponent()
        {
            upPhotoHL.NavigateUrl = Resource.UpPhoto;
            brandHL.NavigateUrl = Resource.Home;
            homeHL.NavigateUrl = Resource.Home;
            voteHL.NavigateUrl = Resource.Vote;
            AccListHL.NavigateUrl = Resource.AccountList;
        }
    }
}